<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding: 0;
        }
        .container{
            width: 400px;
            height: 400px;
            margin:50px auto;
        }
        span,#main{
            display: block;
            width: 100px;
            height: 100px;
            border:2px pink solid;
            float:left;
            margin-left:-2px;
            margin-bottom:-2px;
            text-align: center;
            line-height: 100px;
            border-radius: 16px;
            box-shadow: 2px 2px 3px rgba(226, 86, 109, 0.459);
        }
        #main{
            background-color: rgba(243, 97, 126, 0.651);
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="container">
        <div>
            <span>可视化</span>
            <span>图形学</span>
            <span>操作系统</span>
        </div>
        <div>
            <span>乐事</span>
            <div id="main">抽奖</div>
            <span>大白兔</span>
        </div>
        <div>
            <span>柠檬水</span>
            <span>黑咖啡</span>
            <span>芋泥奶茶</span>
        </div>
    </div>
    <script>
        let main=document.getElementById("main");
        let box=document.getElementsByTagName("span");
        var num=null;
        main.onclick=function(){
            let tem=setInterval(() => {
                if(num!==null){
                    box[num].style.backgroundColor="white";
                }
                num=parseInt(Math.random()*8);
                box[num].style.backgroundColor="rgba(243, 97, 126, 0.651)";
                console.log(num);
            }, 120);

            setTimeout(() => {
                clearInterval(tem)
            }, 3000);
        }
    </script>
</body>
</html>